package com.demo.java.delayqueue;

import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

@Slf4j
public class NettyDelayQueue {
    public static void main(String[] args) {
        Timer timer = new HashedWheelTimer(Executors.defaultThreadFactory());
        for (int j = 0; j < 1000000; j++) {
            for (int i = 1; i <= 20; i++) {
                final int id = i;
                timer.newTimeout(timeout -> {
                    log.info("task" + id);
                }, i * 2, TimeUnit.SECONDS);
            }
        }
    }
}
